﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using Cloud.Model;
using Cloud.BLL;
using System.Configuration;

public partial class Three_Managerment_Problem_one_List_dbsj : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {
                bind1();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void AspNetPager_PageChanged(object sender, EventArgs e)
    {
        try
        {

            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind1();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    //public void bind()
    //{
    //    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
    //    SqlCommand cmd = new SqlCommand("select * from problem where db_num<3 and db_num!=0", connection);
    //    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    //    DataSet ds = new DataSet();
    //    AspNetPager1.PageSize = 10;//设置分页大小 
    //    AspNetPager1.RecordCount = ProblemManager.Bm0_blz_all().Count;//设置总数据条数 
    //    sda.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "problem");//固定不变的 
    //    repeater.DataSource = ds.Tables["problem"];
    //    repeater.DataBind();
    //}

    public void bind1()
    {
        try
        {

            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select * from problem where db_num!=0  and jobnum = " + ((USER_INFO)Session["users"]).USER_ID.ToString() + " ", connection);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            AspNetPager1.PageSize = 10;//设置分页大小 
            AspNetPager1.RecordCount = ProblemManager.Duban_list().Count;//设置总数据条数 
            sda.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "ZS_TYPEINFO");//固定不变的 
            repeater.DataSource = ds.Tables["ZS_TYPEINFO"];
            repeater.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    //public void bind2()
    //{
    //    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
    //    SqlCommand cmd = new SqlCommand("select * from DW where DWBH='"+((USER_INFO)Session["user"]).DEPARTMENT+"'");
    //    SqlDataAdapter sda = new SqlDataAdapter();
    //    DataSet ds = new DataSet();
    //    AspNetPager1.PageSize = 10;//设置分页大小 
    //    AspNetPager1.RecordCount = ProblemManager.Bm0_blz_all().Count;//设置总数据条数 
    //    sda.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "DW");//固定不变的 
    //    repeater.DataSource = ds.Tables["DW"];
    //    repeater.DataBind();

    //}
    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep1") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["source_id"]); //获取填充子类的id 
                IList<Sources> sou = new List<Sources>();
                sou.Add(SourcesManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    public string dbzt(int i)
    {
        try
        {

            String zts = "";
            if (i == 0)
            {
                zts = "未督办";
            }
            else if (i == 1)
            {
                zts = "督办一次";
            }
            else if (i == 2)
            {
                zts = "督办二次";
            }
            else if (i > 2)
            {
                zts = "督查室督办";
            }
            return zts;
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return "";
        }
    }
}